package cn.com.zpark;

import cn.com.zpark.bena.User;
import com.alibaba.fastjson.JSON;

import java.util.ArrayList;
import java.util.List;

/**
 * @PackageName: cn.com.zpark
 * @ClassName: JsonDemo03
 * @Description:
 * @author: RZS
 * @date: 2021/12/22  9:31
 */
public class JsonDemo03 {
    public static void main(String[] args) {
        User<String> user = new User<>();
        user.setId(100);
        user.setName("中关村");

        List<String> list = new ArrayList<>();
        list.add("l1");
        list.add("l2");

        user.setList(list);

        // 将JavaBean对象转成JSON
        String jsonStr = JSON.toJSONString(user);
        System.out.println(jsonStr);

    }
}
